$(function  () {
    layui.use('form', function(){
      var form = layui.form();
      //监听提交
      form.on('submit(login)', function(data){
            var username = $("#user").val();
            var pwd = $("#pwd").val();
            $.post(
                ipurl+'/user/login',
                {
                    user: username,
                    pwd: pwd
                },
                function(result) {
                    layer.open({
                        content: result.msg,
                        end: function(index, layero){
                            if(result.code == 200){
                                console.log(result.data.result[0].TYPE);
                                $.cookie("lname", result.data.result[0].USERNAME, { expires: 7 });
                                $.cookie("ltype", result.data.result[0].TYPE, { expires: 7 });
                                $.cookie("lid", result.data.result[0].ID, { expires: 7 });

                                window.location.href='home.html';
                            }
                        }
                    });
                }
            );
      });
    });
})

function forget(){  
    layui.use('layer', function(){
        var layer = layui.layer;
        layer.msg('请联系管理员');
      });
}

function register(){
    window.location.href='register.html';
}

function registertea(){
    window.location.href='registertea.html';
}